home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
pascal
/
tpb4_src.zip
/
UTILMNU1.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1988-09-13
|
16KB
|
485 lines
{ TPBoard 4.2 Copyright (c) 1987,88 by Jon Schneider & Rick Petersen
Portions Copyright (c) 1986,87 by Steve Fox and Les Archambault
Last modified :: 9-2-88 10:39 pm
}
{$R-} {Range checking off}
{$B-} {Boolean complete evaluation off}
{$S-} {Stack checking off}
{$I+} {I/O checking on}
{$N-} {No numeric coprocessor}
Unit Utilmnu1;
Interface
Uses
TPCrt, Dos, Globals, TAccess,
Core1, Core2, TPSTRING,
Utilmnu2, Dirs;
procedure display_users;
function chat : Boolean;
procedure display_time;
procedure display_stats;
procedure alter_user_params;
{==========================================================================}
Implementation
{ Set the system time using a 6 element byte array which contains
seconds, minutes, hours, day, month, and year.}
procedure SetTAD(var t : tad_array);
var
temp1, temp2, temp3, temp4 : Word;
begin
temp4 := 0; { hundreths of seconds}
temp3 := t[0]; { seconds }
temp2 := t[1]; { minutes }
temp1 := t[2]; { hours }
SetTime(temp1, temp2, temp3, temp4);
temp3 := t[3]; { day }
temp2 := t[4]; { month }
temp1 := t[5]+1900; { year }
SetDate(temp1, temp2, temp3);
end;
procedure display_users;
{ Display user file }
const
col_width = 19;
var
colend, count : Integer;
i : LongInt;
ch, disp_case,
disp_nois : Char;
t : tad_array;
key : StrName;
temp_user_rec : user_list;
Str : StrTAD;
caller : Boolean;
begin {display users}
SetSect(HomName);
if user_rec.access >= 250 then
caller := False
else
caller := True;
repeat
if (not caller) then
begin
WriteLn(Com);
st := prompt('Type of list <A><B><E><Q><U><?> ', 80, 'ES?');
if Length(st) = 1 then
ch := st[1]
else
ch := ' ';
if not(ch in ['A', 'E', 'Q', 'U'])
then WriteLn(Com, '<A>ll, <B>rief, <E>xceptional, <U>n-validated, <Q>uit');
end
else
if user_rec.access >= val_acc then
ch := 'B'
else
ch := 'Q';
if ch in ['A', 'B', 'E', 'U'] then
begin
abort := False;
WriteLn(Com);
WriteLn(Com, 'The user list will be alphabetic by last name,');
WriteLn(Com, 'starting with a character or string you specify.');
WriteLn(Com);
key := prompt('Start [ <CR> for all names]', len_name, 'ES');
if key = ' ' then
begin
ClearKey(IdxF);
NextKey(IdxF, i, key)
end
else
begin
SearchKey(IdxF, i, key);
if not OK then
begin
ClearKey(IdxF);
NextKey(IdxF, i, key)
end
end;
GetTAD(t); count := 0;
Str := FormTAD(t);
if ch = 'E' then
WriteLn(Com, 'Exceptional - access, time, exempt from purge.')
else if ch = 'U' then
Write(Com, 'Unvalidated ');
WriteLn(Com, 'Users As Of: ', Str);
WriteLn(Com);
if (user_rec.lines <> 99) and (not printer_copy) then count := count+2;
if user_rec.access >= 250 then
begin
WriteLn(Com, FileLen(DatF), ' records, ');
if (user_rec.lines <> 99) and (not printer_copy) then Inc(count);
end;
if ch <> 'B' then WriteLn(Com, UsedRecs(DatF), ' users in file.');
if (user_rec.lines <> 99) and (not printer_copy) then
Inc(count);
colend := 999;
while (not brk) and OK do
with temp_user_rec do
begin
GetRec(DatF, i, temp_user_rec);
if (ch = 'B') and (fn <> 'SYSOP') and (access >= val_acc)
then
begin
WriteLn(Com, pad(ln, Succ(len_ln)), ' ', pad(fn, Succ(len_fn)),
' ', pad(cy+',', len_cy+2), ' ', st);
WriteLn(Com, 'Computer: ', pad(ad, Succ(len_ad)), ' Last on: ', laston
[4],
'/', laston[3], '/', laston[5]);
WriteLn(Com);
if (user_rec.lines <> 99) and (not printer_copy) then
begin
Inc(count, 3);
if count >= user_rec.lines then
begin
pause; count := 0;
end;
end;
end
else if (ch = 'A')
or ((ch = 'U') and (access < val_acc))
or ((ch = 'E') and ((access > val_acc) or (limit > val_time)
or test_bit(Flags, 5)))
then if fn <> 'SYSOP' then
begin
WriteLn(Com);
WriteLn(Com, {first line}
ln, ' ', fn, ' ', cy, ', ', st, ' ',
pad(ph, Succ(len_ph)), ' ',
pad(ad, Succ(len_ad)));
WriteLn(Com, {second line}
'Access:', access:4,
' Time Limit:', limit:4);
if shift_lock
then disp_case := 'U'
else disp_case := 'L';
if noisy
then disp_nois := 'N'
else disp_nois := 'Q';
Write(Com, {third line}
'Nulls:', nulls:2,
' Case:', disp_case:2,
' Noisy:', disp_nois:2,
' Conferences:');
if conf_flags > 0 then
begin
for i := 1 to 7 do
if test_bit(conf_flags, i) then Write(Com, ' ', Chr(i+48));
WriteLn(Com);
end
else WriteLn(Com, ' None');
WriteLn(Com, {fourth line}
'Cols:', columns:3,
' Lines:', lines:3,
' Last on: ', laston[4], '/', laston[3], '/', laston[5], ' ',
' Last msg read:', lasthi:5);
Write(Com, {fourth line}
'Uplds:', upload:3,
' Downlds:', download:4,
' Password: ', pw,
' Flags set:');
if Flags > 0 then
begin
for i := 0 to 7 do
if test_bit(Flags, i) then Write(Com, ' ', Chr(i+48));
WriteLn(Com);
end
else WriteLn(Com, ' None');
if (user_rec.lines <> 99) and (not printer_copy) then
begin
count := count+6;
if count >= user_rec.lines then
begin
pause; count := 0;
end;
end;
end;
NextKey(IdxF, i, key)
end;
end; {valid command}
until (ch = 'Q') or (not Online) or caller;
end;
function chat : Boolean;
{ Chat with sysop }
var
Regs : Dos.Registers;
ch : Char;
i, count : Integer;
n : Word;
t : tad_array;
Str : StrStd;
begin
chl := ' ';
OK := op_chat;
if op_chat
then WriteLn(Com, 'Chat requested by Sysop...', BEL, BEL)
else
begin
GetTAD(t);
if (not chat_ok) then
WriteLn(Com, 'Sorry, the Chat function is not active at this time.')
else
if (t[2] < chatstart) or (t[2] > Pred(chatend))
then WriteLn(Com, 'Sorry, the hours to chat are ', chatstart, ':00 to ', chatend,
':00.')
else
begin
WriteLn(Com);
WriteLn(Com, 'Please standby ', user_rec.fn, ' ', user_rec.ln, '.');
WriteLn(Com, 'Will ring for 30 seconds. Type ^C to cancel.');
WriteLn(Com);
Write(Com, '|-------------------------------|', CR, '|');
i := 15;
repeat
Write(BEL, BEL); { BEL is not normally sent to console }
Write(Com, '-+', BEL);
time_count := 0; count := 0;
repeat
ch := GetChar;
Regs.AH := 0;
Intr($1A, Regs);
if Regs.AL <> 0 then
Mem[40:70] := $1;
n := Regs.DX;
if n <> time_count then
begin
time_count := n;
Inc(count);
end;
until (not Online) or (count > 36) or (ch in [ETX, ESC]);
Dec(i);
until (not Online) or (i <= 0) or (ch in [ETX, ESC]);
WriteLn(Com);
if (ch in [ETX, ESC]) and (chl <> ESC)
then WriteLn(Com, 'Cancelled.')
else if chl = ESC
then
begin
WriteLn(Com, 'Sysop is available. Type ^C to exit CHAT...');
OK := True
end
else WriteLn(Com, 'Sorry, the sysop is not available.')
end
end;
if OK then
begin
WriteLn(Com);
in_chat := True;
next_inpstr := '';
repeat
Str := next_inpstr;
GetStr(Str, ch, len_msg, 'AEW');
WriteLn(Com)
until (not Online) or (ch = ETX);
in_chat := False;
chat := False
end
else
begin
WriteLn(Com);
chat := ask('Would you care to leave a message', 'N')
end;
end;
procedure display_time;
{ Display current system time and date }
var
t, tem : tad_array;
Str : StrTAD;
begin
GetTAD(t);
Str := FormTAD(t);
WriteLn(Com, Str);
if (user_rec.access >= 250) or (not remote_copy)
then if ask('Do you want to reset the time', 'N')
then
begin
WriteLn(Com); { Change login time so system doesn't hang up on us }
tem[5] := strint(prompt('Year ', 2, 'E'));
tem[4] := strint(prompt('Month ', 2, 'E'));
tem[3] := strint(prompt('Day ', 2, 'E'));
tem[2] := strint(prompt('Hour ', 2, 'E'));
tem[1] := strint(prompt('Minute', 2, 'E'));
tem[0] := strint(prompt('Second', 2, 'E'));
SetTAD(tem);
GetTAD(login_t);
Str := FormTAD(login_t);
WriteLn(Com, Str);
end;
end;
procedure display_stats;
var
i, days, max : Integer;
t : tad_array;
day_array : array[0..23] of Integer;
procedure show_graph(title : StrPr);
var
i, J : Integer;
factor, scale : Real;
line : StrStd;
begin
WriteLn(Com);
WriteLn(Com, ' ':8, title, ' for the Last ', days, ' Days');
WriteLn(Com);
factor := max/15.0;
for J := 15 downto 1 do
begin
line := ' ';
scale := factor*J;
for i := 0 to 23 do
if day_array[i] > scale
then
begin
line[1+3*i] := '*';
line[2+3*i] := '*'
end;
Write(Com, white, scale:3:0);
i := Length(line);
while line[i] = ' ' do
i := Pred(i);
WriteLn(Com, ' ', yellow, Copy(line, 1, i))
end;
Write(Com, white);
WriteLn(Com, ' 12 1 2 3 4 5 6 7 8 9 10 11 12 1 2 3 4 5 6 7 8 9 10 11')
;
Write(Com, green);
WriteLn(Com, ' |------------- A. M. ---------------|------------- P. M. -------------|')
;
end;
begin { show_stats }
GetTAD(t);
days := Round(greg_to_jul(t[3], t[4], t[5])-greg_to_jul(stat_rec.date[3],
stat_rec.date[4], stat_rec.date[5]));
if days = 0
then days := 1;
max := 0;
for i := 0 to 23 do
begin
day_array[i] := Round((100.0*stat_rec.busy_per_hour[i])/(60.0*days));
if max < day_array[i]
then max := day_array[i]
end;
show_graph('Percent of Average System Usage by Hour')
end;
procedure alter_user_params;
{ Get new user parameters }
var
valid,
continue : Boolean;
ch : Char;
i : Integer;
temp : string[2];
begin
repeat
continue := False;
WriteLn(Com);
st := prompt('Parameter <B><C><L><N><P><S><#><Q><?> ', 80, 'ES?');
WriteLn(Com);
if Length(st) = 1 then ch := st[1]
else ch := '?';
case ch of
'B' :
begin
user_rec.noisy := not user_rec.noisy;
if user_rec.noisy
then WriteLn(Com, 'Prompt bell on.')
else WriteLn(Com, 'Prompt bell off.')
end;
'C' :
begin
WriteLn(Com, 'Current characters per line setting is ', user_rec.columns, '.');
temp := prompt('New setting [40-80]', 2, 'ES');
i := strint(temp);
if (temp = ' ') or (not(i in [40..80]))
then WriteLn(Com, 'Characters per line unchanged.')
else user_rec.columns := i
end;
'L' :
begin
WriteLn(Com, 'Current lines-per-page setting is ', user_rec.lines, '.');
temp := prompt('New setting [10-48 or 99 to inhibit pause]', 2, 'ES');
i := strint(temp);
if (temp = ' ') or (not(i in [10..48, 99]))
then WriteLn(Com, 'Lines-per-page unchanged.')
else user_rec.lines := i
end;
'N' :
begin
WriteLn(Com, 'Currently using ', user_rec.nulls, ' nulls.');
get_nulls
end;
'P' :
begin
get_old_password('Please enter current password', valid);
if valid
then get_new_password
else WriteLn(Com, 'Password unchanged.')
end;
'#' : get_phone;
'Q' : continue := True;
'S' : get_case
else
begin
list('C');
continue := False;
end;
end;
until (continue) or (not Online);
if Online then PutRec(DatF, user_loc, user_rec);
end;
end. { of UTILMNU1.PAS }